import sys

import numpy as np
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget
from PyQt5.QtGui import QPainter, QPen, QBrush
from PyQt5.QtCore import Qt, QRectF, QPointF


class WaferWidget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)

    def paintEvent(self, event):
        diameter = 200  # Diameter of the wafer
        notch_angle = 0  # Angle of the notch in degrees
        notch_width = 10  # Width of the notch
        notch_depth = 5  # Depth of the notch

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        # Draw the wafer
        center = QPointF(self.width() / 2, self.height() / 2)
        radius = diameter / 2
        wafer_rect = QRectF(center.x() - radius, center.y() - radius, diameter, diameter)

        pen = QPen(Qt.black, 2)
        painter.setPen(pen)
        painter.drawEllipse(wafer_rect)

        # Draw the notch
        notch_angle_rad = np.deg2rad(notch_angle)
        notch_x = center.x() + (radius - notch_depth) * np.cos(notch_angle_rad)
        notch_y = center.y() + (radius - notch_depth) * np.sin(notch_angle_rad)

        notch_rect = QRectF(notch_x - notch_width / 2, notch_y, notch_width, -notch_depth)
        painter.setBrush(QBrush(Qt.black))
        painter.drawRect(notch_rect)


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Wafer Diagram")
        self.setGeometry(100, 100, 400, 400)
        self.waferWidget = WaferWidget(self)
        self.setCentralWidget(self.waferWidget)


def main():
    app = QApplication(sys.argv)
    mainWindow = MainWindow()
    mainWindow.show()
    sys.exit(app.exec_())


if __name__ == "__main__":
    main()